package org.xyl.context;

import java.util.*;

/**
 * 意图分类器 - 负责识别用户的意图类型
 */
public class IntentClassifier {
    
    // 诊断意图关键词
    private static final Set<String> DIAGNOSTIC_KEYWORDS = new HashSet<>(Arrays.asList(
        "诊断", "故障", "问题", "不亮", "无法刷新", "无法连接", "错误", "报警", "异常"
    ));
    
    // 客服意图关键词
    private static final Set<String> SERVICE_KEYWORDS = new HashSet<>(Arrays.asList(
        "支持", "规格", "参数", "性能", "安装", "使用", "操作", "说明", "手册"
    ));
    
    /**
     * 分类用户意图
     */
    public UserIntent classifyIntent(String userQuery, Map<String, List<String>> entities) {
        String normalizedQuery = userQuery.toLowerCase();
        
        // 优先检查诊断意图
        for (String keyword : DIAGNOSTIC_KEYWORDS) {
            if (normalizedQuery.contains(keyword)) {
                return UserIntent.DIAGNOSTIC;
            }
        }
        
        // 检查客服意图
        for (String keyword : SERVICE_KEYWORDS) {
            if (normalizedQuery.contains(keyword)) {
                return UserIntent.SERVICE;
            }
        }
        
        // 默认意图
        return UserIntent.DEFAULT;
    }
}